<template>
  <div class="page-box">
    <el-row :gutter="10" type="flex">
      <el-col :span="showFlow?19:24 " class="page-box-form">
        <slot name="form"/>
      </el-col>

      <el-col :span="showFlow?5:0">
        <el-card class="box-card" shadow="never" style="height: 100%">
          <FlowRecord v-if="showFlow" :id="flowId"/>
        </el-card>
      </el-col>
      <div style="clear: both"></div>
    </el-row>
    <el-card shadow="never" class="page-box-d">
      <div>
        <!-- 保存操作 -->
        <el-button  size="small" @click="closeSelectedTag">{{ butShow ? '取消' : '关闭' }}</el-button>
        <!--        <el-button type="primary" size="small" @click="saveForm" v-if="butShow">保存</el-button>-->
        <el-button type="primary" size="small" @click="submit" v-if="butShow">提交</el-button>

      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  model: {
    prop: "details",
    event: "changeDetails",
  },

  props: ["details", "butShow", "flowId"],
  data() {
    return {
      value: "",
      formBus: {},
    };
  },
  computed: {
    visitedViews() {
      return this.$store.state.tagsView.visitedViews;
    },
    showFlow() {
      if (this.flowId) {
        return true;
      } else {
        return false;
      }
    },
  },

  watch: {
    details: {
      handler(val, oldVal) {
        if (!val) return;
        this.formBus = val;
      },
      // 深度观察监听
      deep: true,
      immediate: true,
    },
  },
  created() {
  },
  mounted() {
  },
  methods: {
    // 取消关闭页面
    closeSelectedTag() {
      this.$emit("closeSelectedTag", this.$route);
    },
    // 表单数据(目前只做保存)
    submit() {
      // type 状态判断提交
      this.$emit("submitOn");
    },

    saveForm() {
      this.$emit("saveFormOn");
    }
  },
};
</script>

<style scoped lang="scss">
.page-box {
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.page-box-d {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: end;
  box-sizing: border-box;
}


</style>


